package com.ruoyi.system.service.impl;

import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.constants.CommonConstants;
import com.ruoyi.system.domain.ByExportTask;
import com.ruoyi.system.task.ByExportThreadTask;
import com.ruoyi.system.task.ByFileScanTask;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.ByHistoryFileMapper;
import com.ruoyi.system.domain.ByHistoryFile;
import com.ruoyi.system.service.IByHistoryFileService;

/**
 * HistoryFileService业务层处理
 * 
 * @author ruoyi
 * @date 2024-07-29
 */
@Service
public class ByHistoryFileServiceImpl implements IByHistoryFileService 
{
    @Autowired
    private ByHistoryFileMapper byHistoryFileMapper;

    /**
     * 查询HistoryFile
     * 
     * @param id HistoryFile主键
     * @return HistoryFile
     */
    @Override
    public ByHistoryFile selectByHistoryFileById(Long id)
    {
        return byHistoryFileMapper.selectByHistoryFileById(id);
    }

    @Override
    public ByHistoryFile selectByHistoryFileByFileName(String fileName) {
        return byHistoryFileMapper.selectByHistoryFileByFileName(fileName);
    }

    @Override
    public AjaxResult scanFile() {
        //开线程
        //建立导出任务 状态为0 未完成
        AtomicInteger allCount = new AtomicInteger(0);// 记录处理总条数
        AtomicInteger failCount = new AtomicInteger(0);// 记录失败总条数
        AtomicInteger successCount = new AtomicInteger(0);// 记录成功总条数
        ByFileScanTask byThreadTask = new ByFileScanTask();
        byThreadTask.run();
        return null;
    }

    /**
     * 查询HistoryFile列表
     * 
     * @param byHistoryFile HistoryFile
     * @return HistoryFile
     */
    @Override
    public List<ByHistoryFile> selectByHistoryFileList(ByHistoryFile byHistoryFile)
    {
        return byHistoryFileMapper.selectByHistoryFileList(byHistoryFile);
    }

    /**
     * 新增HistoryFile
     * 
     * @param byHistoryFile HistoryFile
     * @return 结果
     */
    @Override
    public int insertByHistoryFile(ByHistoryFile byHistoryFile)
    {
        return byHistoryFileMapper.insertByHistoryFile(byHistoryFile);
    }

    /**
     * 修改HistoryFile
     * 
     * @param byHistoryFile HistoryFile
     * @return 结果
     */
    @Override
    public int updateByHistoryFile(ByHistoryFile byHistoryFile)
    {
        return byHistoryFileMapper.updateByHistoryFile(byHistoryFile);
    }

    /**
     * 批量删除HistoryFile
     * 
     * @param ids 需要删除的HistoryFile主键
     * @return 结果
     */
    @Override
    public int deleteByHistoryFileByIds(Long[] ids)
    {
        return byHistoryFileMapper.deleteByHistoryFileByIds(ids);
    }

    /**
     * 删除HistoryFile信息
     * 
     * @param id HistoryFile主键
     * @return 结果
     */
    @Override
    public int deleteByHistoryFileById(Long id)
    {
        return byHistoryFileMapper.deleteByHistoryFileById(id);
    }
}
